package fragment;

import android.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;

import com.example.admintor.humaninteraction.Data;
import com.example.admintor.humaninteraction.LoginActivity;
import com.example.admintor.humaninteraction.R;

/**
 * Created by Admintor on 2017/11/28.
 */

public class TwelveFragement extends Fragment implements View.OnClickListener {

    ImageView left_up, left_down, right_up;

    Button up, down, left, right, open;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.activity_twelve, container, false);
        Find_View(view);
        Onclick();
        return view;
    }

    private void Find_View(View view) {
        left_up = (ImageView) view.findViewById(R.id.left_up);
        left_down = (ImageView) view.findViewById(R.id.left_down);
        right_up = (ImageView) view.findViewById(R.id.right_up);
        up = (Button) view.findViewById(R.id.up);
        down = (Button) view.findViewById(R.id.down);
        left = (Button) view.findViewById(R.id.left);
        right = (Button) view.findViewById(R.id.right);
        open = (Button) view.findViewById(R.id.open);
    }

    private void Onclick() {
        left_up.setOnClickListener(this);
        left_down.setOnClickListener(this);
        right_up.setOnClickListener(this);
        up.setOnClickListener(this);
        down.setOnClickListener(this);
        left.setOnClickListener(this);
        right.setOnClickListener(this);
        open.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.left_up:
                LoginActivity.landing.setKeyByUiid(Data.SAO_DI_JI_QI, 6);
                break;
            case R.id.left_down:
                LoginActivity.landing.setKeyByUiid(Data.SAO_DI_JI_QI, 7);
                break;
            case R.id.right_up:
                LoginActivity.landing.setKeyByUiid(Data.SAO_DI_JI_QI, 8);
                break;
            case R.id.up:
                LoginActivity.landing.setKeyByUiid(Data.SAO_DI_JI_QI, 2);
                break;
            case R.id.down:
                LoginActivity.landing.setKeyByUiid(Data.SAO_DI_JI_QI, 3);
                break;
            case R.id.left:
                LoginActivity.landing.setKeyByUiid(Data.SAO_DI_JI_QI, 4);
                break;
            case R.id.right:
                LoginActivity.landing.setKeyByUiid(Data.SAO_DI_JI_QI, 5);
                break;
            case R.id.open:
                LoginActivity.landing.setKeyByUiid(Data.SAO_DI_JI_QI, 1);
                break;
        }
    }
}
